package com.gosophia.accountManagement.action;

import java.net.URLEncoder;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.userManagement.dto.UserAccountDTO;
import com.gosophia.userManagement.ws.UserManagementWebService;
import com.opensymphony.xwork2.ActionContext;

@Controller("UpdateUserAccountAction")
@Scope("prototype")
public class UpdateUserAccountAction extends BaseSupportAction{
    
    private static final long serialVersionUID = 1L;

    private UserAccountDTO userAccountDTO;
    
    private List<Long> selectRoleIds;
	
	@Autowired
	private UserManagementWebService userManagementWebService;
	
	@LogRecord(eventAction="账号管理--更新账号",eventTarget="userAccountDTO")
	public String _execute() throws Exception {
	    
	    userManagementWebService.updateUserAccount(userAccountDTO);
	    
	    
	    //不出异常，认为成功
        super.getRequestResult().setMessage("账号"+userAccountDTO.getUserAccountName()+"更新成功");
        super.getRequestResult().setRsltCode("0");
        ActionContext.getContext().getSession().put("_lastOpResult", super.getRequestResult()); 
		return SUCCESS;
	}

	public UserAccountDTO getUserAccountDTO() {
		return userAccountDTO;
	}

	public void setUserAccountDTO(UserAccountDTO userAccountDTO) {
		this.userAccountDTO = userAccountDTO;
	}

    public List<Long> getSelectRoleIds() {
        return selectRoleIds;
    }

    public void setSelectRoleIds(List<Long> selectRoleIds) {
        this.selectRoleIds = selectRoleIds;
    }
}
